package com.px.chapter_Dec_1.russianGame;

import java.awt.*;
import java.util.Random;

public class ShapeFactory {
    private static int[][][] shapes = {
            {
                    {0, 0, 0, 0},
                    {0, 0, 0, 0},
                    {1, 1, 1, 1},
                    {0, 0, 0, 0},
            },
            {
                    {0, 1, 0, 0},
                    {0, 1, 0, 0},
                    {0, 1, 1, 0},
                    {0, 0, 0, 0},
            },
            {
                    {0, 0, 0, 0},
                    {0, 1, 1, 0},
                    {0, 1, 1, 0},
                    {0, 0, 0, 0},
            },
            {
                    {0, 0, 1, 0},
                    {0, 0, 1, 0},
                    {0, 1, 1, 0},
                    {0, 0, 0, 0},
            },
            {
                    {0, 0, 0, 0},
                    {0, 1, 0, 0},
                    {1, 1, 1, 0},
                    {0, 0, 0, 0},
            },
            {
                    {0, 0, 0, 0},
                    {0, 1, 1, 0},
                    {1, 1, 0, 0},
                    {0, 0, 0, 0},
            },
            {
                    {0, 0, 0, 0},
                    {0, 1, 1, 0},
                    {0, 0, 1, 1},
                    {0, 0, 0, 0},
            }
    };
    private static Color[] colors = {new Color(0xFF3030), new Color(0xEE9A49), new Color(0xC71585),
            new Color(0x98FB98), new Color(0x6495ED), new Color(0x551A8B), new Color(0x8B8989)};

    private ShapeFactory() {
    }

    public static Shape getShape() {
        Random random = new Random();
        int index = random.nextInt(7);
        int[][] shapeData = shapes[index].clone();
        for (int i = 0; i < shapeData.length; i++)
            shapeData[i] = shapes[index][i].clone();
        Shape shape = new Shape();
        shape.setData(shapeData);
        shape.setColor(colors[index]);
        return shape;
    }

}